<?php
/**
 * SpiderProductDirver.php class file.
 * @author wudg <544038230@qq.com>
 * @date 2020/10/23- 9:43 上午
 */

namespace common\drivers;


use common\exception\DriverException;

/**
 * 下载商品组件
 * Class SpiderProductDriver
 * @package common\drivers
 */
class SpiderProductDriver
{
    /**
     *
     * @param string $name
     * @param array $cookies
     * @param array $headers
     * @return mixed
     * @throws DriverException
     */
    public function getSpiderDriver(string $name,array $cookies=[],array $headers =[])
    {
        $classPath = "common\\drivers\\spiderProduct\\".$name;

        $this->className = $name;
        if(class_exists($classPath))
        {
            return  new $classPath($cookies,$headers);
        }else{
            throw new DriverException('未知的下载组件'.$name.'，请先完善好组件再调用');
        }
    }
}